<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改元素样式属性</title>
    <style>
        #root{
            width: 200px;
            height: 200px;
            background-color: green;
        }
    </style>
</head>

<body>
    <div id="root">
    </div>
    <div class="tao" style="background-color: palevioletred;width: 200px;height: 200px;">
        <button>x</button>
        <div class="er" style="width: 100px;height: 100px;margin: 0 50%;background-color: green;"></div>
    </div>
</body>
<script>
/* 
    ele.style
    ele.className
*/
let root=document.getElementById('root')
root.style.backgroundColor='yellow'

document.querySelector('button').onclick=function (){
    document.querySelector('div.er').style.display='none'
    this.style.display='none'
}
</script>

</html>